<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
        }

        .box {
            position: relative;

            width: 1000px;
            height: 50px;
            margin-top: 100px;
            margin-left: 100px;
            overflow: hidden;
            line-height: 50px;
            background-color: aquamarine;
        }

        ul {
            position: absolute;
            left: 0;
            top: 0;
            list-style: none;
            width: 1748px;
        }

        ul li {
            float: left;
            margin-right: 30px;
            position: absolute;
            white-space: nowrap;

            animation: scrollLeft 10s linear infinite;
            
            animation-play-state: paused;
        }

        ul li:nth-child(5) {
            margin-right: 0;
        }

        ul li a {
            text-decoration: none;
            color: black;
        }

        ul li a:hover {
            color: red;
        }

        @keyframes scrollLeft {
            0% {
                transform: translateX(0);
            }

            100% {
                transform: translateX(-100%);
            }
        }
    </style>
</head>

<body>
    <div class="box">
        <ul>
            <li><a href="#"> NOI系列活动标准竞赛环境(2016年11月08日更新)</a></li>
            <li><a href="#"> NOI linux系统及安装文档下载(2016年10月8日更新)</a></li>
            <li><a href="#"> NOI Linux 2.0发布，将于9月1日起正式启用！</a></li>
            <li><a href="#"> NOI Linux及相关说明文档下载</a></li>
            <li><a href="#"> NOI系列活动标准竞赛环境(2012年3月20日更新)</a></li>
        </ul>
    </div>

    <script>
        let isPaused = false;
        const ul = document.querySelector('ul');
        const box = document.querySelector('.box');
        const links = ul.querySelectorAll('li');
        const totalWidth = Array.from(links).reduce((acc, link) => acc + link.offsetWidth + 30, 0); 

        ul.style.width = `${totalWidth}px`;
        box.addEventListener('mouseover', () => {
            isPaused = true;
            ul.style.animationPlayState = 'paused';
        });

        box.addEventListener('mouseout', () => {
            isPaused = false;
            if (!isAnimatingBackward) {
                ul.style.animationPlayState = 'running';
            }
        });

        let isAnimatingBackward = false;

        function resetAnimation() {
            ul.style.transition = 'none';
            ul.style.transform = 'translateX(0)';
            isAnimatingBackward = false;
            setTimeout(() => {
                ul.style.transition = 'transform 10s linear';
                if (!isPaused) {
                    ul.style.animationPlayState = 'running';
                }
            }, 10); 
        }

        ul.addEventListener('animationiteration', (e) => {
            if (e.target === ul) {
                resetAnimation();
            }
        });

        
        ul.style.animation = 'none';

        function playAnimation(speed) {
            const duration = speed || 10; 
            ul.style.animationDuration = `${duration}s`;
            ul.style.animationName = 'scrollLeft';
            if (!isPaused) {
                ul.style.animationPlayState = 'running';
            }
        }

        window.onload = () => {
            playAnimation(10); 
        };
    </script>
</body>

</html>